<template>
	<view class="u-skeleton">
		<u-sticky bg-color="#ffffff" h5-nav-height="0">
			<view class="u-flex u-p-24 bgw">
				<view style="font-size: 52upx;" class="color-orange">{{detail.avgScore}}</view>
				<view class="u-p-l-15">
					<view class="">
						<u-rate :count="5" v-model="detail.avgScore" active-icon="star-fill" inactive-icon="star-fill" active-color="#FFB41A" inactive-color="#E8E8EA" disabled size="30"></u-rate>
					</view>
					<view class="u-font-24 u-m-t-12">
						全部评论({{total}})
					</view>
				</view>
			</view>
		</u-sticky>
		
		<view v-for="v in list">
			<evaluate-item :border="true" :detail="v"></evaluate-item>
			<!-- <u-gap height="20"></u-gap> -->
		</view>
		<!-- <view class="u-p-20" v-if="skeletonList.length">
			<view v-for="v in skeletonList">
				<view class="good-item">
					<view class="good-item-img-wrap u-skeleton-fillet">
						<image src="/static/images/icon-index-list.png" mode="aspectFill"></image>
					</view>
					<view class="u-p-20">
						<view class=" u-skeleton-rect">标题</view>
						<view class=" u-m-t-10 u-skeleton-rect">￥</view>
					</view>
				</view>
				<u-gap height="20"></u-gap>
			</view>
		</view> -->
		<u-gap height="20"></u-gap>
		<g-loadmore :status="loadmoreStatus"></g-loadmore>
		<u-gap height="20"></u-gap>
	</view>
	<u-skeleton :loading="skeletonLoading" :animation="true" bgColor="#F9F9F9"></u-skeleton>
</template>

<script setup>
	import store from '@/store/index.js'; //需要引入store

	import {
		ref,
		reactive,
		computed,
		getCurrentInstance,
		watch
	} from 'vue'
	const {
		proxy,
	} = getCurrentInstance()
	const {
		baseImgUrl
	} = proxy;
	const {
		nav,
		navLogin
	} = proxy.$util;
	import {
		onReady,
		onLoad,
		onShow,
		onPageScroll,
		onShareAppMessage
	} from '@dcloudio/uni-app'
	import mixins from '@/common/js/mixins.js';
	const {
		shareAppMessage
	} = mixins();
	import mixinList from '@/common/js/mixinList.js';
	const {
		total,
		current_page,
		page_size,
		last_page,
		apiPath,
		loading,
		list,
		searchParams,
		getList,
		getNextList,
		loadmoreStatus,
		searchClear,
		searchConfirm
	} = mixinList();
	const props = defineProps({
		sid: {
			type: [String, Number],
			default: '',
		},
		isShare: {
			type: [String, Number],
			default: '',
		},
	})
	searchParams.sid = props.sid

	const skeletonLoading = ref(true)
	const skeletonList = ref([1, 2,3,4])
	watch(loadmoreStatus, (newV) => {
		if (newV != 'loading') {
			skeletonLoading.value = false;
			skeletonList.value = []
		}
	})
	apiPath.value = 'getProductEvaluate'
	const detail = reactive({});
	const getData = () =>{
		proxy.$u.api.getProductDetail(props.sid).then(res => {
			// console.log(res);
			let {
				code,
				msg,
				data
			} = res;
			if (code != 200) {
				uni.$u.toast(msg || '错误');
				return;
			}
			for (let key in res.data) {
				detail[key] = data[key]
			}

		}).catch(res => {
			// skeletonLoading.value = false
		})
	}

	onReady(() => {
		console.log('onReady')
	})
	onLoad(async (d) => {
		console.log('onLoad', d)
		getList(1);
		getData();
	})
	onShow(async () => {
		// store.commit('set_userRole', 'user')
	})
	onPageScroll(e => {

	})
</script>

<style scoped lang="scss">


</style>